package com.example.document

import androidx.lifecycle.viewModelScope
import com.example.document.entity.DocListEntity
import com.example.document.entity.DocStatus
import com.witmed.lib_base.BaseViewModel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch

class DocumentViewModel:BaseViewModel<DocmentRepo,DocStatus> (){
    override fun createState(): DocStatus {
        return DocStatus(false,false,ArrayList())
    }

    override fun createResp(): DocmentRepo {
        return DocmentRepo()
    }

    fun selDocuments(){
        viewModelScope.launch {
            val map = hashMapOf<String, Any>(Pair("userId", 1), Pair("page", 1))
            ComFlow(resp.selDocments(map))
                .collect{
                    val list = it as DocListEntity
                    mutableContainer.updateUiState { copy(docStatue=true,loadState=false,data=list.data) }
                }
        }
    }
}